package puzzle.projecteuler.p100;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import java.net.URLDecoder;

public class Problem042 {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		
		String[] ds = readData();

		int count = 0;
		for (String d: ds) {
			if (triangle(d)) {
				count ++;
			}
		}
		System.out.println(count);
	}
	
	public static boolean triangle(String a) {
		int s = 0;
		for (int i = 0; i < a.length(); i ++) {
			s += a.charAt(i) - 'A' + 1;
		}
		int t = (int)Math.floor(Math.sqrt(8*s+1));
		return t*t == 8*s+1; 
	}

	public static String[] readData() throws IOException {

		URL url = Problem018.class.getResource("Problem042.txt");
		File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));

		BufferedReader br = new BufferedReader(new FileReader(file));
		String line = br.readLine();
		br.close();
		return line.replace("\"", "").split(",");
	}
}
